package week5;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
/**
 * Created by dell on 2017/3/26.
 */
public class TryCatchFinallyFileUtil3 {
    public static String readFile(String name) throws FileNotFoundException {
        StringBuilder text = new StringBuilder();
        try (Scanner console = new Scanner(new FileInputStream(name))){
            while (console.hasNext()) {
                text.append(console.nextLine());
                text.append('\n');
            }
        }catch (FileNotFoundException ex) {
            ex.printStackTrace();
            throw ex;
        }return text.toString();
    }
}
